<!DOCTYPE html> 
<html xmlns:th="http://www.thymeleaf.org"> 
<head> 
	<title>首页</title> 
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head> 
<body> 
<div class="container">
	<h1>密钥信息录入</h1><br>
	当前时间：<a th:text="${#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd HH:mm:ss')}"></a>

	<p>
	<form id="formID">
	  <div class="form-group">
	    <label for="kname">用户名称</label>
	    <input type="text" class="form-control" id="kname" placeholder="">
	  </div>
	  <div class="form-group">
	    <label for="mac">MAC地址</label>
	    <input type="text" class="form-control" id="mac" placeholder="">
	  </div>
	  <div class="form-group">
	    <label for="cpu">CPU序列号</label>
	    <input type="text" class="form-control" id="cpu" placeholder="">
	  </div>
	  <div class="form-group">
	    <label for="boss">主板序列号</label>
	    <input type="text" class="form-control" id="boss" placeholder="">
	  </div>
	  
	  <button type="button" class="btn btn-default" id="sub">提 交</button>
	</form>
	</p>
	</div>
</body> 
<script>
$(function(){
	$("#sub").bind("click",function(){	
		//请求参数
	    var list = {'kname':$('#kname').val(),
	    		'mac':$('#mac').val(),
	    		'cpu':$('#cpu').val(),
	    		'boss':$('#boss').val()};
	    console.info(list);
	    $.ajax({
	        //请求方式
	        type : "POST",
	        dataType : "json",
	        contentType : "application/json",
	        //请求地址
	        url : "api/saveKey/",
	        //数据，json字符串
	        data :  JSON.stringify(list),
	        //请求成功
	        success : function(result) {
	            console.log(result);
	        },
	        //请求失败，包含具体的错误信息
	        error : function(e){
	            console.log(e.status);
	            console.log(e.responseText);
	        }
	    });
	});
});

</script>
</html>